﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BusinessTier.Facade.Implementation;
using BusinessTier.Facade.Interface;
using Domain;
using Domain.Type;
using WebMVC.Models;

namespace WebMVC.Controllers
{
    public class ServiceController : Controller
    {
        private IProductService productService;
        public ServiceController() : this(new ProductService())
        {}

        public ServiceController(IProductService productService)
        {
            this.productService = productService;
        }

        public ActionResult Design()
        {
            return View();
        }

        public ActionResult Printing()
        {
            var sheetPricelist = (List<ProductPrice>)productService.GetProductPriceListByType(ProductTypeCode.SHEET_PRINTING);
            
            var model = new SheetPrintViewModel
            {
                A3PriceList = new List<PriceListItemViewModel>(),
                A4PriceList = new List<PriceListItemViewModel>(),
                SRA3PriceList = new List<PriceListItemViewModel>(),
            };

            foreach (var m in sheetPricelist)
            {
                if (m.FormFactor.NameEn == "A4")
                {
                    model.A4PriceList.Add(new PriceListItemViewModel
                    {
                        Quantity = m.Quantity,
                        Price1x0 = m.Price1x0,
                        Price4x1 = m.Price4x1,
                        Price4x4 = m.Price4x4,
                        Price4x0 = m.Price4x0,
                        Price1x1 = m.Price1x1,
                    });
                }else if (m.FormFactor.NameEn == "A3")
                {
                    model.A3PriceList.Add(new PriceListItemViewModel
                    {
                        Quantity = m.Quantity,
                        Price1x0 = m.Price1x0,
                        Price4x1 = m.Price4x1,
                        Price4x4 = m.Price4x4,
                        Price4x0 = m.Price4x0,
                        Price1x1 = m.Price1x1,
                    });
                }else if (m.FormFactor.NameEn == "SRA3")
                {
                    model.SRA3PriceList.Add(new PriceListItemViewModel
                    {
                        Quantity = m.Quantity,
                        Price1x0 = m.Price1x0,
                        Price4x1 = m.Price4x1,
                        Price4x4 = m.Price4x4,
                        Price4x0 = m.Price4x0,
                        Price1x1 = m.Price1x1,
                    });
                }

            }
            
            return View(model);
        }


        public ActionResult Mail()
        {
            return View();
        }
    }
}
